package com.common.base;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.entity.sys.query.SysQuery;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

public abstract class BaseService<M extends BaseMapper<E>, E extends BaseEntity> extends ServiceImpl<M, E>{

    @Resource
    protected HttpServletRequest httpServletRequest;


    /**
     * 系统设置模块统一的传参参数设置
     */
    public Map<String,Object> sysParams(SysQuery queryVo){
        Map<String,Object> map = new HashMap<>();
        if (StrUtil.isNotBlank(queryVo.getName())){
            map.put("name",queryVo.getName());
        }
        if (StrUtil.isNotBlank(queryVo.getCode())){
            map.put("code",queryVo.getCode());
        }
        if (queryVo.getParentId() != null){
            map.put("parentId",queryVo.getParentId());
        }
        if (queryVo.getId() != null){
            map.put("id",queryVo.getId());
        }
        if (queryVo.getState() != null){
            map.put("state",queryVo.getState());
        }
        return map;
    }

}
